<?php
//引入类文件自动加载
require_once __DIR__ . '/../autoload.php';
//引入用户信息检查类
use src\Check;
//接受post参数
$username=trim($_REQUEST['school']['username']) ?: $_REQUEST['username'];
$password=trim($_REQUEST['school']['password']) ?: $_REQUEST['pwd'];
//new一个用户信息检查对象,并传入参数
$Result= new Check\UserInfoCheck($username,$password);
$Result->check();
//结果判断,并返回
if($Result->checkResult == true){
	$expire=time()+60*60*24*30*6;
    setcookie("school[username]", $username, $expire);
    setcookie("school[password]",$password,$expire);
	$time=time()+60*60*24*30*54;
	if(!isset($_COOKIE['messageID'])){
	    setcookie("messageID",0,$time);
	}
	$modifyPasswordTime=time()+60*60*24*30*54;
	if(!isset($_COOKIE[$username."modifyPasswordCount"])){
	    setcookie($username."modifyPasswordCount",3,$time);
	}
	exit(json_encode(array('code'=>1,'msg'=>'登录成功')));
}else{
	exit(json_encode(array('code'=>0,'msg'=>'登录失败')));
}
